package com.zd.kids.ui.view;

import android.content.Context;
import android.content.Intent;
import android.widget.TextView;

import com.blankj.utilcode.util.ToastUtils;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BottomPopupView;
import com.zd.kids.R;
import com.zd.kids.ui.activity.CommonH5Activity;
import com.zd.kids.ui.activity.InputBookCodeActivity;
import com.zd.kids.ui.activity.JoinClassComputerActivity;

import androidx.annotation.NonNull;

/**
 * @ClassName: com.zd.kids.ui.view
 * @Description:
 * @Author: hyy
 * @Date: 2020/6/19
 * @Time: 10:21 AM
 */
public class SelectBookTypePopupWindow extends BottomPopupView {
    Context context;

    String titleName;

    public SelectBookTypePopupWindow(@NonNull Context context, String name) {
        super(context);
        this.context = context;
        this.titleName = name;
    }

    private TextView tvName;


    @Override
    protected void init() {
        super.init();

        tvName = findViewById(R.id.tv_name);
        tvName.setText(titleName);

        findViewById(R.id.tv_close).setOnClickListener(view -> dismiss());

        findViewById(R.id.tv_buy).setOnClickListener(view -> {

            Intent intent = new Intent(context, InputBookCodeActivity.class);
            intent.putExtra(InputBookCodeActivity.INPUT_CODE_KEY, "InputBookCodeActivity");
            context.startActivity(intent);

            dismiss();
        });

        findViewById(R.id.tv_detail).setOnClickListener(view -> {

            Intent intent = new Intent(context, CommonH5Activity.class);
            intent.putExtra(CommonH5Activity.URL_PATH_KEY, "https://www.gapsk.com/");
            context.startActivity(intent);

            dismiss();
        });

    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.layout_select_booktype_type;
    }


    public void showView() {
        new XPopup.Builder(getContext())
                .dismissOnTouchOutside(false)
                .asCustom(this)
                .show();
    }


}
